// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/iot/api/IotCertificateApiApi'

import ListClass from '@api/iot/model/CertificateReq'
import AddClass from '@api/iot/model/CertificateGenerateReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 列表 —————————————————————————————— //

  async getList(param, TIP = '查询列表') {
    const DTO = CORE.grpcDTO(ListClass, param)
    const resp = await CORE.grpc(TIP, CLIENT, 'queryCertificateList', DTO)
    return [resp.total, resp.data || []]
  },

  // —————————————————————————————— 增 —————————————————————————————— //

  async add(one, TIP = '新增') {
    const DTO = CORE.grpcDTO(AddClass, one)
    await CORE.grpc(TIP, CLIENT, 'generateCertificate', DTO)
    return CORE.grpcOK(TIP)
  },
}
